<template>
  <div>
    <!-- @search="onSearch"
    -->
    <van-search show-action placeholder="请输入搜索关键词" @cancel="onCancel" />
    <van-dropdown-menu>
      <van-dropdown-item v-model="value1" disabled :options="option1" />
      <van-dropdown-item v-model="value2" :options="option2" title="价格" />
      <van-dropdown-item v-model="value3" :options="option3" title="分类" />
    </van-dropdown-menu>
    <div class="Commoditymodule">
      <div class="Productdetails" v-for="good in RoductsearchList.goodsList" :key="good.id" @click="getdetails(good.id)">
        <img :src="good.list_pic_url">
        <div class="spanlist">
          <span class="span1">{{good.name}}</span>
          <span class="span2">￥{{good.retail_price}}元</span>
        </div>

      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Listofgoods',
  data() {
    return {
      alue1: 0,
      value1: 0,
      value2: 'b',
      value3: 'b',
      option1: [{ text: '综合', value: 0 }],
      option2: [
        { text: '价格从高到低', value: 'b' },
        { text: '价格从低到高', value: 'c' }
      ],
      option3: [
        { text: '全部', value: 'b' },
        { text: '居家', value: 'c' }
      ],
      //商品列表
      RoductsearchList: {},
      filterCategory: [],
      order: 'desc'
    }
  },
  props: ['transmitlist'],
  mounted() {
    this.getpRoductsearchList()
  },
  computed: {},
  methods: {
    //加载组件时请求商品列表
    getpRoductsearchList() {
      this.$store.dispatch('getpRoductsearchList', { keyword: this.transmitlist, order: this.order })
      setTimeout(() => {
        this.RoductsearchList = this.$store.state.login.RoductsearchList
        this.filterCategory = this.$store.state.login.RoductsearchList.filterCategory
      }, 500)
    },
    //点击取消按钮
    onCancel() {
      //回退到上一个路由
      this.$router.back(-1)
    },
    //点击商品跳转到相关的商品详情
    getdetails(id) {
      this.$router.push({ name: 'productDetail', params: { id } })
    }
  }
}
</script>

<style lang="less" scoped>
.Commoditymodule {
  padding: 0% 2%;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  .Productdetails {
    width: 48%;
    background-color: #fff;
    display: flex;
    justify-content: center;
    flex-direction: column;
    margin-top: 3%;
    padding: 2% 0%;
    .spanlist {
      margin-top: 4%;
      display: flex;
      flex-direction: column;
      .span1 {
        display: flex;
        justify-content: center;
      }
      .span2 {
        display: flex;
        justify-content: center;
        margin-top: 2%;
        color: #880000;
      }
    }
  }
}
</style>